package com.serkol.ams.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.serkol.ams.bean.MyPage;
import com.serkol.ams.bean.MyPageOld;
import com.serkol.ams.entity.Category;
import com.serkol.ams.mapper.CategoryMapper;
import com.serkol.ams.modal.SqlFeildModal;
import com.serkol.ams.service.CategoryService;
import com.serkol.handler.MyLambdaQueryWrapper;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
* @author pingan
* @description 针对表【category】的数据库操作Service实现
* @createDate 2022-09-19 16:34:25
*/
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category>
    implements CategoryService{

    @Override
    public MyPage<Map<String, Object>> findByList(int pageSize, int current) {
        MyLambdaQueryWrapper<Category> queryWrapper=new MyLambdaQueryWrapper<>();
        queryWrapper.select(SqlFeildModal.getCategoryListFeild());
        queryWrapper.tableAs(Category.class,"x");
     //   queryWrapper.last("ID=0");
        queryWrapper.isNotNull(Category::getName);

        Page<Map<String, Object>> page=new Page<>(current,pageSize);

        Page<Map<String, Object>> mapPage = this.baseMapper.selectMapsPage(page, queryWrapper);
        return MyPage.parsePage(mapPage);
    }
}




